package com.winteam.Controler;

import com.winteam.Bean.Admin;
import com.winteam.dao.DbConnection;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class UserSelect {
    //查询操作员方法
    public static Object[][] geUserInfo(){
        String sql="select username, adminnmae from account;";
        ResultSet resultSet= DbConnection.query(sql);
        ArrayList<Admin> list=new ArrayList<Admin>();
        try {
            while (resultSet.next()) {
                Admin userinfo=new Admin();
                userinfo.setUsername(resultSet.getString(1));
                userinfo.setAdminname(resultSet.getString(2));
                list.add(userinfo);
            }
        }catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //泛型集合，转化为二维数组
        Object[][] body=new Object[list.size()][2];
        for (int i = 0; i < list.size(); i++) {
            body[i][0]=list.get(i).getAdminname();
            body[i][1]=list.get(i).getUsername();
        }
        return body;
    }
}
